package ui.dnd;

import ui.FormRow;

import javax.swing.*;
import java.awt.datatransfer.Transferable;
import java.awt.dnd.DragSourceDragEvent;
import java.awt.dnd.DragSourceMotionListener;

/**
 * Created with IntelliJ IDEA.
 * User: Deshun
 * Date: 2/18/13
 * Time: 12:55 PM
 * To change this template use File | Settings | File Templates.
 */
public class DragAndDropTransferHandler  extends TransferHandler implements DragSourceMotionListener {

    public DragAndDropTransferHandler() {
        super();
    }

    public Transferable createTransferable(JComponent c) {
        if(c instanceof FormRow ) {
            Transferable tip = (FormRow ) c;
            return tip;
        }

        return null;
    }
    @Override
    public void dragMouseMoved(DragSourceDragEvent dsde) {
    }

    public int getSourceActions(JComponent c) {
        if(c instanceof FormRow ) {
            return TransferHandler.COPY;
        }

        return TransferHandler.NONE;
    }
}
